{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d84f7be2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import mlflow\n",
    "\n",
    "TRACKING_URL = \"http://127.0.0.1:5000\"\n",
    "mlflow.set_tracking_uri(TRACKING_URL)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "293ac71d",
   "metadata": {},
   "outputs": [],
   "source": [
    "run_id = '6dd459b11b4e48dc862f4e1019d166f6'\n",
    "logged_model = f'runs:/{run_id}/model'\n",
    "\n",
    "loaded_model = mlflow.pyfunc.load_model(logged_model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "031645d6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import mlflow\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e5e6825e",
   "metadata": {},
   "outputs": [],
   "source": [
    "loaded_model = mlflow.pyfunc.load_model('s3://mlflow-models-alexey/1/6dd459b11b4e48dc862f4e1019d166f6/artifacts/model/')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "64f389c2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "aaf7ad20",
   "metadata": {},
   "outputs": [],
   "source": [
    "request = {\n",
    "    'lpep_pickup_datetime': '2021-01-01 00:15:56',\n",
    "    'PULocationID': 43,\n",
    "    'DOLocationID': 151,\n",
    "    'passenger_count': 1.0,\n",
    "    'trip_distance': 1.01\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6256f61d",
   "metadata": {},
   "outputs": [],
   "source": [
    "features = {}\n",
    "features['PU_DO'] = '%s_%s' % (request['PULocationID'], request['DOLocationID'])\n",
    "features['trip_distance'] = request['trip_distance']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "0b3a195c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([14.8285286])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "loaded_model.predict(features)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6fce5f72",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
